import request from '@/utils/request'

export function signin(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

export function signup(data) {
  return request({
    url: '/register',
    method: 'post',
    data
  })
}
export function forword(data) {
  return request({
    url: '/changepassword',
    method: 'post',
    data
  })
}
export function phonelogin(data) {
  return request({
    url: '/mobilelogin',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/user/getuserinfo',
    method: 'post',
    params: { }
  })
}

export function logout() {
  return request({
    url: '/admins/logout',
    method: 'post'
  })
}

export function sendCode(data) {
  return request({
    url: '/sendcode',
    method: 'post',
    data
  })
}

// 对应接口的列表接口index
export function fetchUserList(query) {
  return request({
    url: '/users.json',
    method: 'get',
    params: query
  })
}

// 对应接口的详情接口show
export function fetchUser(id) {
  return request({
    url: `/users/${id}.json`,
    method: 'get',
    params: {}
  })
}

// 对应接口的创建接口post create
export function createUser(data) {
  return request({
    url: '/users.json',
    method: 'post',
    data
  })
}

// 对应接口的更新接口put update
export function updateUser(id, data) {
  return request({
    url: `/users/${id}.json`,
    method: 'put',
    data
  })
}

// 对应接口的更新接口delete
export function deleteUser(id) {
  return request({
    url: `/users/${id}.json`,
    method: 'delete',
    params: {}
  })
}

// 我的园区
export function fetchMyParks(data) {
  return request({
    url: `/yuanqu/mylist`,
    method: 'post',
    data
  })
}

// 我的项目
export function fetchMyProjects(data) {
  return request({
    url: `/project/myprojectlist`,
    method: 'post',
    data
  })
}

// 修改密码
export function editPassword(data) {
  return request({
    url: `/changepassword`,
    method: 'post',
    data
  })
}

export function editPhone(data) {
  return request({
    url: `/changePhonenumber`,
    method: 'post',
    data
  })
}
